package leetcode;

/**
 * @Project : AlgorithmLearning
 * @Package : Leetcode
 * @File : Q0096.java
 * @Author : WangRuoyu
 * @Date 2023/11/5 21:50
 */


public class Q0096 {
    public int numTrees(int n) {
        int[] f = new int[n + 1];
        f[0] = 1;
        f[1] = 1;
        for (int i = 2; i <= n; i++) {
            for (int j = 0; j < i; j++) {
                f[i] += f[j] * f[i - j - 1];
            }
        }
        return f[n];
    }

    public static void main(String[] args) {
        Q0096 sl = new Q0096();
        int n = 3;
        System.out.println(sl.numTrees(n));
    }
}